﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Tasks;
namespace Day2
{
    public partial class SendSMSPage : PhoneApplicationPage
    {
        public SendSMSPage()
        {
            InitializeComponent();
			bntSend.Click +=new System.Windows.RoutedEventHandler(bntSend_Click);
        }

        private void bntBrowsePhoneNumber_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {
        	// TODO: Add event handler implementation here.
			PhoneNumberChooserTask pnum = new PhoneNumberChooserTask();
			pnum.Completed +=new System.EventHandler<Microsoft.Phone.Tasks.PhoneNumberResult>(pnum_Completed);
        	pnum.Show();
		}

        private void pnum_Completed(object sender, Microsoft.Phone.Tasks.PhoneNumberResult e)
        {
        	// TODO: Add event handler implementation here.
			if(e.TaskResult == TaskResult.OK){
				txtPhoneNumber.Text = e.PhoneNumber;
				
			}
        }

        private void bntSend_Click(object sender, System.Windows.RoutedEventArgs e)
        {
        	// TODO: Add event handler implementation here.
			
			SmsComposeTask sms = new SmsComposeTask();
			sms.To = txtPhoneNumber.Text;
			sms.Body = txtMessage.Text;
			sms.Show();
			
			/*
			PhoneCallTask call  =new PhoneCallTask();
			call.PhoneNumber = txtPhoneNumber.Text;
			call.DisplayName = "My Mom";
			call.Show();
			*/
			
        }
    }
}
